package cn.springcloud.fix.auth.controller;

import cn.springcloud.fix.common.core.base.R;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/token")
public class TokenController {

    @GetMapping("/get")
    public R<Object> get() {
        return R.SUCCESS();
    }

    @GetMapping("/passwd")
    public R<Object> passwd(String username, String password) {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(10);
        String encoderPasswd = encoder.encode(password);
        return R.SUCCESS(encoderPasswd);
    }

    /*public static void main(String[] args) {
        //$2a$10$VU8mjPDb5xEdlhB391Y1nOUB7Vn7V42sa3vDO7rhddAxVFF/c9MGS
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(10);
        String encoderPasswd = encoder.encode("123");
        System.out.println(encoderPasswd);
    }*/
}
